package com.adam.springbuck.controller;

import com.adam.springbuck.entity.Person;
import com.adam.springbuck.service.BuckRPCService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BuckRPCController {

    @Autowired
    BuckRPCService buckRPCService;

    /**
     * RPC远程调用方式1:使用restTemplate
     * @param id
     * @return
     */
    @RequestMapping(value = "/json", method = RequestMethod.GET)
    @ResponseBody
    public Person getRPCRestTemp(Long id){

        Person person = buckRPCService.getRPCRestTemp(id);
        System.out.println(person);
        return person;
    }

    /**
     * RPC远程调用方式2:使用http
     * @param id
     * @return
     */
    @RequestMapping(value = "/httpRPC", method = RequestMethod.GET)
    @ResponseBody
    public Person httpRPC(Long id){

        Person person = buckRPCService.httpRPC(id);
        System.out.println(person);
        return person;
    }


}
